﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:controls="clr-namespace:Rabbit.Controls;assembly=Rabbit.Controls"
        xmlns:behavior="clr-namespace:MicroBlogClient.Behaviors"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <DataTemplate x:Key="StatusItemTemplate">
        <DataTemplate.Resources>
            <Storyboard x:Key="YellowFade">
                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" FillBehavior="Stop">
                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFEFF76" />
                    <SplineColorKeyFrame KeyTime="00:00:20" Value="#19FEFF76" />
                </ColorAnimationUsingKeyFrames>
            </Storyboard>
        </DataTemplate.Resources>
        <DockPanel Margin="0,10,0,10" x:Name="grid" Background="Transparent">
            <!--User Picture-->
            <Border VerticalAlignment="Top" Width="40">
                <Border BorderBrush="White" DockPanel.Dock="Left" CornerRadius="5" Height="40" Width="40" BorderThickness="1">
                    <Image Stretch="UniformToFill"
                           behavior:CommandHelper.MouseEnter="{Binding ShowUserInformationCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                           behavior:CommandHelper.MouseEnterParameter="{Binding User}" 
                           behavior:CommandHelper.MouseLeave="{Binding HideUserInformationCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                          Source="{Binding User.ProfileImageUrl, Converter={StaticResource ImageConverter}, IsAsync=True,Mode=OneTime}" />
                </Border>
            </Border>
            <!--Status Text-->
            <StackPanel Margin="10,0,0,0">
                <!--User/Status Information-->
                <StackPanel Orientation="Horizontal">
                    <TextBlock TextWrapping="Wrap" Canvas.Top="0" Width="Auto">
                        <Hyperlink
                            CommandParameter="{Binding User.ScreenName}"
                            Command="{Binding OpenUserPageCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}">
                             <Run Text="{Binding User.ScreenName}"/></Hyperlink></TextBlock>
                    <controls:ImageEx Visibility="{Binding User.Verified, Converter={StaticResource BooleanToVisibilityConverter}}" Source="{StaticResource CertificateUser}" Height="18" Width="20"/>
                    <TextBlock Foreground="Gray" Margin="5,0,0,0" 
                                   ToolTip="{Binding CreatedAt, Converter={StaticResource ResourceKey=DateTimeFormatConverter},ConverterParameter={}yyy-MM-dd HH:mm:ss,StringFormat={}发表于{0}}"
                                   Text="{Binding CreatedAt, Converter={StaticResource ResourceKey=DateTimeFormatConverter}}"/>
                </StackPanel>
                <!--Status Inforamtion:Text and Picture(if exist)-->
                <DockPanel Margin="10,10,0,0">
                    <!--Status text-->
                    <controls:TextBlockEx 
                        behavior:CommandHelper.OnUserNameClicked="{Binding OpenUserPageCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                            Foreground="{DynamicResource StatusForegroundBrush}"
                                          LineHeight="20" Text="{Binding Text}"
                                          DockPanel.Dock="Top"
                                          TextWrapping="Wrap"/>

                    <controls:ImageEx  Stretch="None" 
                                       MaxHeight="200" 
                                       MaxWidth="400"
                            behavior:CommandHelper.PreviewMouseLeftButtonDown="{Binding ShowLargeImageCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                            behavior:CommandHelper.PreviewMouseLeftButtonDownParameter="{Binding MiddlePic}" 
                            Source="{Binding SmallPic, Converter={StaticResource ImageConverter}, IsAsync=True,Mode=OneTime}"  
                            Cursor="Hand"
                            x:Name="statusImage" HorizontalAlignment="Left">
                        <controls:ImageEx.ToolTip>点击看大图</controls:ImageEx.ToolTip>
                    </controls:ImageEx>
                </DockPanel>
                <!--forwared status(if is forwarded status) Inforamtion:Text and Picture(if exist)-->
                <TextBlock Margin="10,5,0,0" Visibility="{Binding InReplyToStatusText, Converter={StaticResource StringToVisibilityConverter}}">
                    		<Border BorderBrush="{DynamicResource FowardedStatusLeftLineBrush}" BorderThickness="1,0,0,0">
                    			<TextBlock Margin="5,0,0,0"> 
                    					<TextBlock  VerticalAlignment="Top">
                                            <Hyperlink CommandParameter="{Binding InReplyToScreenName}"
                                               Command="{Binding OpenUserPageCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}">
                    								<TextBlock Text="{Binding InReplyToScreenName,StringFormat=@\{0\}:}"/> 
                    							</Hyperlink></TextBlock> 
                                    <Run Text=" "/>
                    					<TextBlock Visibility="{Binding IsMouseOver, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}" >
                                            <Hyperlink CommandParameter="{Binding}"
                                                    Command="{Binding ForwardOrignalStatusCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                                                    x:Name="linkForward">
                                                 <!--Click="ForwardStatusHandler"-->
                                                <Run Text="{Binding InReplyToTransmitCount,StringFormat={}转原文({0})}"/></Hyperlink>
                    							<TextBlock Margin="3,0,4,0"/>
                                            <Hyperlink CommandParameter="{Binding}" 
                                                    Command="{Binding ReplyOrignalStatusCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                                                       x:Name="linkReplyComment">
                                                <Run Text="{Binding InReplyToCommentsCount,StringFormat={}评原文({0})}"/>
                                            </Hyperlink></TextBlock> <LineBreak/>
                    					<StackPanel>
                    						<controls:TextBlockEx
                                                behavior:CommandHelper.OnUserNameClicked="{Binding OpenUserPageCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                                                Padding="5,0,0,0"
                                                LineHeight="20"
                                                Foreground="{DynamicResource FowardedStatusForegroundBrush}"
                                                Text="{Binding InReplyToStatusText, IsAsync=True}"
                                                TextWrapping="Wrap"/>
                    						<controls:ImageEx  Visibility="{Binding InReplyToHasImage, Converter={StaticResource BooleanToVisibilityConverter}}"
                    							Source="{Binding InReplyToSmallImageUrl, Converter={StaticResource ImageConverter}, IsAsync=True,Mode=OneTime}" 
                                                               Cursor="Hand"
                                                               x:Name="statusReplyToImage"
                                                                behavior:CommandHelper.PreviewMouseLeftButtonDown="{Binding ShowLargeImageCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                                                                behavior:CommandHelper.PreviewMouseLeftButtonDownParameter="{Binding InReplyToMiddleImageUrl}" 
                                                               HorizontalAlignment="Left"
                                                               Stretch="None">
                                                               <!--PreviewMouseLeftButtonDown="statusImage_PreviewMouseLeftButtonUp"-->
                    							<controls:ImageEx.ToolTip>点击看大图</controls:ImageEx.ToolTip>
                    						</controls:ImageEx>
                    					</StackPanel></TextBlock>
                    		</Border></TextBlock>
                    <TextBlock Margin="0,10,0,0">
                       <TextBlock Text="{Binding Source}" Foreground="Gray" />
                        <TextBlock  Margin="5,0,0,0">
                            <Hyperlink CommandParameter="{Binding}"
                                       Command="{Binding QuickForwardStatusCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                                       >
                                       <!--Click="QuickForwardHandler"--> 
                                <Run Text="{Binding TransmitCount,StringFormat={}速转}"/></Hyperlink>
                            <Hyperlink CommandParameter="{Binding}"
                                       Command="{Binding ForwardStatusCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                                      >
                                 <!--Click="ForwardStatusHandler"--> 
                                <Run Text="{Binding TransmitCount,StringFormat={}转({0})}"/></Hyperlink>
                        	<Hyperlink CommandParameter="{Binding}"
                                       Command="{Binding ReplyStatusCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                                       >
                                <!--Click="ReplyStatusHandler"-->
                               <Run Text="{Binding CommentsCount,StringFormat={}评(0)}"/></Hyperlink>
                        	<Hyperlink CommandParameter="{Binding Id}"
                                       Command="{Binding AddStatusToFavoritesCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" 
                                      >
                                 <!--Click="AddStatusToFavoritesHandler"-->
                                <Run Text="收藏"/></Hyperlink>
                            <Hyperlink CommandParameter="{Binding}"
                                      Command="{Binding CopyCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}">
                                 复制</Hyperlink>
                        </TextBlock>
                    </TextBlock>
                </StackPanel>
            </DockPanel>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding IsNew}" Value="true">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource YellowFade}" x:Name="YellowFade_BeginStoryboard" />
                    </DataTrigger.EnterActions>
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
</ResourceDictionary>